<template>
    <a-modal
        v-model="showModal"
        width="1000px"
    >
        <slot slot="title" name="title"/>
        <a-table style="min-height: 400px;" :columns="columns" :data-source="data" :pagination=" pagination">
            <template #account="account">
                {{ account || '系统' }}
            </template>
            <template #detail="detail">
                <a-tooltip :title="detail">
                    <section class="overflow">{{ detail }}</section>
                </a-tooltip>
            </template>
        </a-table>
        <template #footer>
            <a-button @click="showModal = false" type="primary">好的</a-button>
        </template>
    </a-modal>
</template>
<script>
import {tableMixins} from '@/utils/mixins'
import {getOperationLogs} from '@/api/common'

export default {
    name: 'OrderLog',
    mixins: [tableMixins],
    props: {
        type: {
            type: String,
            required: true
        }
    },
    data() {
        return {
            loading: false,
            showModal: false,
            columns: [
                {title: '日志时间', align: 'center', dataIndex: 'createTime'},
                {
                    title: '事件类型',
                    align: 'center',
                    dataIndex: 'statusDesc',
                    scopedSlots: {customRender: 'statusDesc'}
                },
                {title: '操作账号', align: 'center', dataIndex: 'account', scopedSlots: {customRender: 'account'}},
                {
                    title: '事件详情',
                    width: '50%',
                    align: 'center',
                    ellipsis: true,
                    dataIndex: 'detail',
                    scopedSlots: {customRender: 'detail'}
                }
            ],
            data: [],
            entityId: ''
        }
    },
    methods: {
        open(entityId) {
            this.showModal = true
            this.entityId = entityId
            this.getData()
        },
        getData() {
            this.loading = true
            const send = {
                eventType: this.type,
                entityId: this.entityId,
                pageNo: this.pageNum,
                pageSize: this.rowsNum
            }
            getOperationLogs(send).then(data => {
                this.data = data.items
                this.total = data.rowCount
            }).finally(() => this.loading = false)
        },
    }
}
</script>
